package com.rc.saas.tenant.service.shop;

import com.rc.saas.tenant.mapper.shop.ShopGoodsClassMapper;
import com.rc.saas.tenant.model.shop.ShopGoodsClass;
import com.rc.saas.tenant.model.shop.ShopGoodsClassExample;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ShopGoodsClassServiceImpl implements ShopGoodsClassService {
    @Autowired
    private ShopGoodsClassMapper shopGoodsClassMapper;

    @Override
    public ShopGoodsClassMapper getMapper() {
        return shopGoodsClassMapper;
    }

    @Override
    public List<ShopGoodsClass> listByTenantCode(String tenantCode) {
        ShopGoodsClassExample example=new ShopGoodsClassExample();
        example.createCriteria().andTenantCodeEqualTo(tenantCode);
        return shopGoodsClassMapper.selectByExample(example);
    }

    @Override
    public void initData(String tenantCode) {
        ShopGoodsClass shopGoodsClass0 =new ShopGoodsClass();
        shopGoodsClass0.setTenantCode(tenantCode);
        shopGoodsClass0.setClassType("0");
        shopGoodsClass0.setClassParentId(0L);
        shopGoodsClass0.setDepth("1");
        shopGoodsClass0.setClassName("test");
        shopGoodsClass0.setCreatedTime(new Date());

        ShopGoodsClass shopGoodsClass1 =new ShopGoodsClass();
        BeanUtils.copyProperties(shopGoodsClass0, shopGoodsClass1);
        shopGoodsClass1.setClassType("1");
        shopGoodsClass1.setClassName("test");
        ShopGoodsClass shopGoodsClass2 =new ShopGoodsClass();
        BeanUtils.copyProperties(shopGoodsClass0, shopGoodsClass2);
        shopGoodsClass2.setClassType("2");
        shopGoodsClass2.setClassName("test");

        shopGoodsClassMapper.insertSelective(shopGoodsClass0);
        shopGoodsClassMapper.insertSelective(shopGoodsClass1);
        shopGoodsClassMapper.insertSelective(shopGoodsClass2);

    }
}
